# class Car:
#     wheels = 4
#     def drive(self):
#         print('行驶')
# class Car:
#     def drive(self):
#         self.wheels = 4
# car = Car()
# car.drive()
# car.wheels = 3
# print(car.wheels)
# car.color = "黑色"
# print(car.color) # 实例方法

# 类方法
# class Car:
#     @classmethod
#     def stop(cls):
#         print("我是类方法")
# car = Car()
# car.stop()
# Car.stop()  # 可以用类

# 静态方法
# class Car:
#     wheels = 3
#     @staticmethod
#     def test():
#         print("我是静态方法")
#         print(f"类属性的值为{Car.wheels}")
# car = Car()
# car.test()
# Car.test()

# 私有成员
# class Car:
#     __wheels = 4
#     def __drive(self):
#         print("开车")

# class Car:
#     __wheels = 4
#
#     def __drive(self):
#         print("行驶")
#     def test(self):
#         print(f"轿车有{self.__wheels}个车轮")
#         self.__drive()
# car = Car()

# 构造方法
# 无参结构
# class Car:
#     def __init__(self):
#         self.color = "红色"
#     def drive(self):
#         print(f"车的颜色为：{self.color}")
# car_one = Car()
# car_one.drive()
# car_two = Car()
# car_two.drive()

# 有参结构
# class Car:
#     def __init__(self,color):
#         self.color = color
#     def drive(self):
#         print(f"车的颜色为：{self.color}")
# car_one = Car("红色")
# car_one.drive()
# car_two = Car("蓝色")
# car_two.drive()

# 课内实践
# class Circle:
#     def __init__(self, radius):
#         self.radius = radius
#     def get_perimeter(self):
#         perimeter = 2 * 3.14 * self.radius
#         print(f"圆的周长是：{perimeter}")
#     def get_area(self):
#         area = 3.14 * self.radius * self.radius
#         print(f"圆的面积是：3.14")
# circle_one = Circle("5")
# circle_one.get_perimeter()
# circle_two = Circle("5")
# circle_two.get_area()

# class Circle:
#     def __init__(self, tup, radius, color):
#         self.center = tup
#         self.radius = radius
#         self.color = color
#     def perimeter(self):
#         return 3.14 * 2 * self.radius
#     def area(self):
#         return 3.14 * self.radius * self.radius
# circle = Circle((0,0),5,"蓝色")
# print(circle.perimeter())
# print(circle.area())

# 析构方法
# class Car:
#     def __init__(self):
#         self.color = "蓝色"
#         print("对象被创建")
#     def __del__(self):
#         print("对象被销毁")
# car = Car()
# print(car.color)
# del car
# print(car.color)

# 好友管理系统
# class Mate_system:
#     def __init__(self, name, number, sex, age):
#         self.name = name
#         self.number = number
#         self.sex = sex
#         self.age = age
#     def __del__(self, a):
#         self.name = a
#         print("已删除该好友")
#     def remark_friend(self):
#         print(f"备注好友：{self.name, self.number, self.sex, self.age}")
#     def show_friend(self):
#         print(f"{Mate_system}")
#     def friend_array(self, friend, schoolmate, family):
#         self.friend = []
#         self.schoolmate = []
#         self.family = []
#         print(f"朋友组：{self.friend}")
#         print(f"同学组：{self.schoolmate}")
#         print(f"家人组：{self.family}")
#     def exit(self):
#         return 0
# mate_one = Mate_system("张三",193300002, '男', '22')

# class Friend:
#     def __init__(self):
#         self.friend_li = []
#     def welcome(self):
#         print("* * 欢迎使用好友管理系统 * *")
#         print("1:添加好友")
#         print("2:删除好友")
#         print("3:备注好友")
#         print("4:展示好友")
#         print("5:好友分组")
#         print("6:退出")
#         while True:
#             option = input("请选择功能\n")
#             if option == '1':
#                 self.add_friend()
#             elif option == '2':
#                 self.del_friend()
#             elif option == '3':
#                 self.modify_friend()
#             elif option == '4':
#                 self.show_friend()
#             elif option == '5':
#                 self.group_friend()
#             elif option == '6':
#                 break
#
#     def add_friend(self):
#         add_friend = input("请输入要添加的好友：")
#         self.friend_li.append(add_friend)
#         print('添加好友成功')
#     def get_all_friends(self):
#         new_li = []
#         for friend_li_elem in self.friend_li:
#             if type(friend_li_elem) == dict:
#                 [new_li.append(dict_elem_name) for
#                  dict_elem in friend_li_elem.values()
#                  for dict_elem_name in dict_elem]
#             else:
#                 new_li.append(friend_li_elem)
#         return new_li
#     def get_all_groups(self):
#         groups = []
#         for friend_li_elem in self.friend_li:
#             if type(friend_li_elem) == dict:
#                 groups.append(friend_li_elem)
#         return groups
#     def get_all_groups_name(self):
#         groups_name = []
#         for i in self.get_all_groups():
#             for j in i:
#                 groups_name.append(j)
#         return groups_name
#     def del_friend(self):
#         if len(self.friend_li) != 0:
#             del_name = input("请输入删除好友姓名：")
#             if del_name in self.friend_li:
#                 self.friend_li.remove((del_name))
#                 print('删除成功')
#             else:
#                 if del_name in self.get_all_friend():
#                     for group_data in self.get_all_groups():
#                         for group_friend_li in group_data.values():
#                             if del_name in group_friend_li:
#                                 group_friend_li.remove(del_name)
#                                 continue
#                             print('删除成功')
#         else:
#             print('好友列表为空')
#
#     def modify_friend(self):
#         friends = self.get_all_friends()
#         if len(friends) == 0:
#             print('好友列表为空')
#         else:
#             before_name = input("请输入要修改的好友姓名：")
#             after_name = input("请输入修改后的好友姓名：")
#             if before_name in self.friend_li:
#                 friend_index = self.friend_li.index(before_name)
#                 self.friend_li[friend_index] = after_name
#                 print("备注成功")
#             elif before_name not in self.friend_li:
#                 for friend_li_elem in self.friend_li:
#                     if type(friend_li_elem) == dict:
#                         for dict_elem in friend_li_elem.values():
#                             if before_name in dict_elem:
#                                 modify_index = (
#                                     dict_elem.index(before_name))
#                                 dict_elem[modify_index] = after_name
#                 print('备注成功')
#     def show_friend(self):
#         print("1.展示所有好友")
#         print("2.展示分组名称")
#         option_show = input("请输入选项：")
#         groups = self.get_all_groups()
#         friends = self.get_all_friends()
#         if option_show == '1':
#             if len(friends) == 0:
#                 print("当前没有任何好友")
#             else:
#                 print(friends)
#         elif option_show == '2':
#             if len(friends) == 0:
#                 print("当前没有任何好友")
#             else:
#                 if len(groups) == 0:
#                     print("当前没有任何分组")
#                 else:
#                     for dict_groups in groups:
#                         for group_name in dict_groups:
#                             print(group_name)
#                     is_show_group = input("是否展示组内好友：y/n\n")
#                     if is_show_group == 'y':
#                         show_group_name = input("请输入查看的分组名称")
#                         for i in groups:
#                             if show_group_name in i:
#                                 show_index = groups.index(i)
#                                 print(groups[show_index][show_group_name])
#
#     def group_friend(self):
#         create_group = input("是否创建新的分组y/n\n")
#         friends = self.get_all_friends()
#         if create_group == 'y':
#             if len(friends) == 0:
#                 print("当前没有任何好友")
#             else:
#                 group_name = input("请输入分组名称：\n")
#                 group_name_li = list()
#                 print(friends)
#                 friend_name = input("请输入好友名称：\n")
#                 if friend_name in friends:
#                     all_friend = []
#                     for friend_li_elem in self.friend_li:
#                         if type(friend_li_elem) == dict:
#                             [all_friend.append(dict_friends) for
#                              dict_elem in friend_li_elem.values()
#                              for dict_friends in dict_elem]
#                         else:
#                             all_friend.append(friend_li_elem)
#                     if friend_name in all_friend:
#                         group_name_li.append(friend_name)
#                         self.friend_li.remove(friend_name)
#                         friend_dict = dict()
#                         friend_dict[group_name] = group_name_li
#                         self.friend_li.append(friend_dict)
#                     else:
#                         print("请输入正确的名称")
#                 else:
#                     print('请输入正确的好友名称')
#         elif create_group == 'n':
#             current_groups = self.get_all_groups()
#             print('当前分组：')
#             for current_group in current_groups:
#                 for group_name in current_group:
#                     print(group_name)
#             add_group = input('请选择添加的组：\n')
#             if add_group in self.get_all_groups_name():
#                 add_name = input('请选择添加的好友名称：\n')
#                 if add_name in self.friend_li:
#                     if add_name not in current_groups:
#                         add_group_index = self.get_all_groups_name().index(add_group)
#                         current_groups[add_group_index][add_group].append(add_name)
#                 else:
#                     print('该好友已在其他分组中')
#             else:
#                 print('请输入正确的组名')
# if __name__ == '__main__':
#     friend = Friend()
#     friend.welcome()

# 生词本
# import os
# class User:
#     def welcome(self):
#         print("欢迎使用生词本")
#         print("1.用户注册")
#         print("2.用户登录")
#         print("3.用户注销")
#         print("4.修改密码")
#         print("5.退出")
#         while True:
#             option = input("请选择功能（登录）\n")
#             if option == '1':
#                 self.register()
#             elif option == '2':
#                 self.login()
#             elif option == '3':
#                 self.cancel()
#             elif option == '4':
#                 self.modify()
#             elif option == '5':
#                 print('谢谢使用')
#                 break
#     def register(self):
#         if os.path.exists('./info.txt') is not True:
#             with open('./info.txt', mode='w', encoding='utf8') as f:
#                 f.write('')
#         person_info = {}
#         name = input("请输入注册用户名：\n")
#         password = input("请输入注册密码：\n")
#         person_info['姓名'] = name
#         person_info['密码'] = password
#         with open('./info.txt', mode='a+', encoding='utf8') as info_data:
#             info_data.write(str(person_info) + '\n')
#
#     def convert_data(self):
#         info_li = []
#         with open('./info.txt', mode='r+', encoding='utf8') as f:
#             info_data = f.readlines()
#             for i in info_data:
#                 info_dict = dict()
#                 step_one = i.replace('{','').replace(']','')
#                 step_two = step_one.split(':')
#                 info_dict["姓名"] = step_two[1].split(',')[0].replace("'", '').strip()
#                 info_dict["密码"] = step_two[2].split(',')[0].replace("'", '').strip()
#                 info_li.append(info_dict)
#         return info_li
#
#     def register(self):
#         if os.path.exists('./info.txt') is not True:
#             with open('./info.txt', mode='w', encoding='utf8') as f:
#                 f.write('')
#         name_li = []
#         info_li = self.convert_data()
#         person_info = {}
#         name = input("请输入注册用户名：\n")
#         for i in info_li:
#             name_li.append(i['姓名'])
#         if name in name_li:
#             print('用户已注册')
#         else:
#             password = input("请输入注册密码：\n")
#             person_info['姓名'] = name
#             person_info['密码'] = password
#             with open('./info.txt', mode='a+', encoding='utf8') as info_data:
#                 info_data.write(str(person_info) + '\n')
#     def login(self):
#         if os.path.exists('./info.txt') is not True:
#             print('当前无数据，请先注册')
#         else:
#             name_li = []
#             info_li = convert_data()
#             name = input("请输入登录用户名：\n")
#             password = input("请输入登录密码：\n")
#             for i in info_li:
#                 name_li.append(i['姓名'])
#             if name in name_li:
#                 modify_index = name_li.index(name)
#                 if password == info_li[modify_index]['密码']:
#                     print('密码成功')
#                 else:
#                     print('用户名或密码不正确')
#             else:
#                 print('用户名或密码不正确')
#     def cancel(self):
#         if os.path.exists('./info.txt') is not True:
#             print('当前无数据，请先注册')
#         else:
#             cancel_name = input("请输入注销的用户\n")
#             cancel_password = input("请输入密码\n")
#             name_li = []
#             info_li = self.convert_data()
#             for i in info_li:
#                 name_li.append(i['姓名'])
#             if cancel_name in name_li:
#                 cancel_index = name_li.index(cancel_name)
#                 if cancel_password == info_li[cancel_index]['密码']:
#                     info_li.pop(cancel_index)
#                     with open('./info.txt', mode='w+', encoding='utf8') as f:
#                         f.write('')
#                     for i in info_li:
#                         with open('./info.txt', mode='a+', encoding='utf8') as info_data:
#                             info_data.write(str(i) + '\n')
#                     print('用户注销成功')
#                 else:
#                     print('用户名或密码不正确')
#             else:
#                 print('注销的用户不存在')
#     def modify(self):
#         if os.path.exists('./info.txt') is not True:
#             print('当前无数据，请先注册')
#         else:
#             name_li = []
#             info_li = self.convert_data()
#             modify_name = input("请输入用户名：\n")
#             password = input("请输入旧密码：\n")
#             for i in info_li:
#                 name_li.append(i['姓名'])
#             if modify_name in name_li:
#                 modify_index = name_li.index(modify_name)
#                 if password == info_li[modify_index]['密码']:
#                     new_password = input("请输入新密码\n")
#                     info_li[modify_index]['密码'] = new_password
#                     with open('./info.txt', mode='w+', encoding='utf8') as f:
#                         f.write('')
#                     for i in info_li:
#                         with open('./info.txt', mode='a+', encoding='utf8') as info_data:
#                             info_data.write(str(i) + '\n')
#                 else:
#                     print("用户名或密码不正确")
#             else:
#                 print("用户名或密码不正确")
#
# class Recitelogic:
#     def __init__(self):
#         self.user_name = ''
#     def welcome(self, name):
#         self.user_name = name
#         print('='*20)
#         print(name + '的生词记录本')
#         print('1.查看单词')
#         print('2.背单词')
#         print('3.添加新单词')
#         print('4.删除单词')
#         print('5.清空单词')
#         print('6.退出')
#         print('='*20)
#         while True:
#             option = input("请输入功能选项（生词本）：\n")
#             if option == '1':
#                 self.see_words()
#             elif option == '2':
#                 self.recite_words()
#             elif option == '3':
#                 self.add_words()
#             elif option == '4':
#                 self.del_words()
#             elif option == '5':
#                 self.clear_words()
#             elif option == '6':
#                 break
#
#     def conver_data(self):
#         info_li = []
#         with open('./' + self.user_name + '.txt', encoding='utf8') as info_data:
#             info_data = f.readlines()
#             for i in info_data:
#                 for i in info_data:
#                     info_dict = dict()
#                     step_one = i.replace('{', '').replace('}', '')
#                     step_two = step_one.split(':')
#                     en = step_two[0].split(',')[0].replace("'", '').strip()
#                     zh = step_two[1].split(',')[0].replace("'", '').strip()
#                     info_dict[en] = zh
#                     info_li.append(info_dict)
#         return info_li
#     def see_words(self):
#         if os.path.exists('./' + self.user_name+'.txt') is not True:
#             print('当前无数据，请先添加单词')
#         else:
#             words_data = self.conver_data()
#             if len(words_data) == 0:
#                 print("生词本内容为空")
#             else:
#                 with open('./'+self.user_name+'.txt', mode='r+', encoding='utf8') as f:
#                     info_data = f.readlines()
#                 for i in info_data:
#                     print(i.replace('{', '').replace('}', '').strip())
#
#     def recite_words(self):
#         if os.path.exists('./'+self.user_name+'.txt') is not True:
#             print('当前无数据，请先添加单词')
#         else:
#             words_data = self.conver_data()
#             if len(words_data) == 0:
#                 print("生词本内容为空")
#             else:
#                 words_li = self.conver_data()
#                 en_li = []
#                 for i in words_li:
#                     for j in i.keys():
#                         en_li.append(j)
#                 for random_word in set(en_li):
#                     random_word_index = en_li.index(random_word)
#                     words_zh = words_li[random_word_index][random_word]
#                     in_words = input("请输入" + random_word + '翻译' + ':\n')
#                     if in_words == words_zh:
#                         print('太棒了')
#                     else:
#                         print('再想想')
#     def add_words(self):
#         if os.path.exists('./' + self.user_name + '.txt') is not True:
#             with open('./' + self.user_name + '.txt', mode='w+', encoding='utf8') as f:
#                 f.write('')
#         word_data_dict = dict()
#         new_words = input("请输入新单词：")
#         words_li = self.conver_data()
#         en_li = []
#         for i in words_li:
#             for j in i.keys():
#                 en_li.append(j)
#         if new_words in en_li:
#             print('添加的单词已存在')
#         else:
#             translate = input('请输入单词翻译：')
#             if os.path.exists('./' + self.user_name + '.txt') is not True:
#                 with open('./' + self.user_name +'.txt', mode='w', encoding='utf8') as f:
#                     f.write('')
#             word_data_dict[new_words] = translate
#             with open('./' + self.user_name + '.txt', mode='a+', encoding='utf8') as info_data:
#                 info_data.write(str(word_data_dict) + "\n")
#     def del_words(self):
#         if os.path.exists('./' + self.user_name + '.txt') is not True:
#             print('当前无数据，请先添加单词')
#         else:
#             words_data = self.conver_data()
#             if len(words_data) == 0:
#                 print("生词本内容为空")
#             else:
#                 words_li = self.conver_data()
#                 en_li = []
#                 for i in words_li:
#                     for j in i.keys():
#                         en_li.append(j)
#                 del_words = input("请输入要删除的单词：\n")
#                 if del_words not in en_li:
#                     print('删除的单词不存在')
#                 else:
#                     del_words_index = en_li.index(del_words)
#                     words_li.pop(del_words_index)
#                     print('单词删除成功')
#                     with open('./' + self.user_name + '.txt', mode='w+', encoding='utf8') as f:
#                         f.write('')
#                     for i in words_li:
#                         with open('./' + self.user_name + '.txt', mode='w+', encoding='utf8') as f:
#                             f.write('')
#                         for i in words_li:
#                             with open('./' + self.user_name + '.txt', mode='a+',encoding='utf8') as info_data:
#                                 info_data.write(str(i) + '\n')
#     def clear_words(self):
#         if os.path.exists('./' + self.user_name + '.txt') is not True:
#             print('当前无数据，请先添加单词')
#         else:
#             with open('./' + self.user_name + '.txt', mode='w+', encoding='utf8') as f:
#                 f.write('')
#     def login(self):
#         from 第8章.生词本.recite import ReciteLogic
#         if os.path.exists('./info.txt') is not True:
#             print('当前无数据，请先注册')
#         else:
#             ...
#             if name in name_li:
#                 modify_index = name_li.index(name)
#                 if password == info_li[modify_index]['密码']:
#                     print('登录成功')
#                     ReciteLogic().welcome(name)
#                     ...
# if __name__ == '__main__':
#     p = User()
#     p.welcome()

# 封装
# class Person:
#     def __init__(self,name):
#         self.name = name
#         self.__age = 1
#     def set_get(self,new_age):
#         if 0 < new_age <= 120:
#             self.__age = new_age
#     def get_age(self):
#         return self.__age

# 继承
# class House(object):
#     def live(self, color):
#         print("go")
# class Car(object):
#     def live(self, color):
#         print("ss")
# class Tour(House, Car):
#     pass
# tour_A = Tour()
# tour_A.live('红色')
# tour_A.live('搜索')
# 如果同名则调用第一个

# class Test:
#     count = 21
#     def print_num(self):
#         count = 20
#         self.count += 20
#         print(count)
# test = Test()
# test.print_num()

class Course:
    def __init__(self):
        self.number = 1001
        self.name = "语文"
        self.teacher = "张老师"
        self.__location = "2号教学楼3层305室"

    def show_info(self):
        return ("""
        课程编号：%d
        课程名称：%s
        任课教师：%s
        上课地点：%s
        """ % (self.number, self.name, self.teacher, self.__location))
course = Course()
print(course.show_info())